<?php 
// 允许跨域资源访问：CORS
    header("Access-Control-Allow-Origin:*");
// 从 POST 请求中获取注册用户信息
    $username = $_POST["username"];
    $password = $_POST["password"];
    $phone = $_POST["phone"];
  /* 保存到数据库中 */
    $conn = mysqli_connect("localhost", "root", "root", "h1806");
// SQL
    $sql = "INSERT INTO project (username, password, phone) VALUES ('$username', '$password', '$phone')";
// 执行SQL
    $result = mysqli_query($conn, $sql);
    if ($result){
        $arr = array("res_code"=>1, "res_message"=>"success");
          echo json_encode($arr);
    }
    else{
        $arr = array("res_code"=>-1, "res_message"=>"failed：" . mysqli_error($conn));
        echo json_encode($arr);
    }
// 关闭数据库连接
    mysqli_close($conn);
 ?>
